package Utils;

import java.util.StringTokenizer;

import static Utils.Symbols.*;
import static java.lang.Integer.*;

public class Util {
    public static int max(int a, int b) {
        if (a > b) return a;
        return b;
    }

    public static void mySleep(int time) {
        try {
            Thread.sleep(time);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void myWait(Object obj) {
        println(" waiting");
        try {
            obj.wait();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static boolean lessThan(int A[], int B[]) {
        for (int j = 0; j < A.length; j++) {
            if (A[j] > B[j]) return false;
        }
        for (int j = 0; j < A.length; j++) {
            if (A[j] < B[j]) return true;
        }
        return false;
    }

    public static int maxArray(int A[]) {
        int v = A[0];
        for (int aA : A) {
            if (aA > v) v = aA;
        }
        return v;
    }

    public static String writeArray(int A[]) {
        StringBuffer s = new StringBuffer();
        for (int aA : A) {
            s.append(String.valueOf(aA)).append(" ");
        }
        return s.toString();
    }

    public static void readArray(String s, int A[]) {
        StringTokenizer st = new StringTokenizer(s);
        for (int aA : A) {
            aA = parseInt(st.nextToken());
        }
    }

    public static int searchArray(int A[], int x) {
        for (int j = 0; j < A.length; j++) {
            if (A[j] == x) return j;
        }
        return -1;
    }

    public static void println(String s) {
        if (Symbols.debugFlag) {
            System.out.println(s);
            System.out.flush();
        }
    }
}
